using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MSRI.SmsService;
using MSRI.HelperClasses;
namespace Hello_World
{
    public partial class Form1 : Form
    {
        public SmsServiceClass SmsService = null;
        public Form1()
        {
            InitializeComponent();
            try
            {
                SmsService = new SmsServiceClass("Hello_World");
                SmsService.OnDeliveryReportReceived += new OnDeliveryReportDelegate(SmsService_OnDeliveryReportReceived);
                SmsService.OnSmsReceived += new OnSmsReceivedDelegate(SmsService_OnSmsReceived);
                // Use SmsService.SendSms(SmsClass Sms) to send a Sms
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }

        //
        // Your Code for Processing a received Sms goes here
        //
        SmsResponseClass SmsService_OnSmsReceived(SmsClass SmsMessage)
        {
            // Compose a Response Message
            SmsResponseClass Response = new SmsResponseClass();
            SmsClass SmsItem = new SmsClass();
            SmsItem.Body = "Your Response";
            SmsItem.Number = SmsMessage.Number;
            Response.AddResponseSms(SmsItem);
            return Response;
        }

        //
        // Your Code for Processing a deliveryreport goes here
        //
        void SmsService_OnDeliveryReportReceived(DeliveryReportClass DeliveryReport)
        {
            if (DeliveryReport.Status == DeliveryStatusEnum.Sent)
            {
                // Message Sent
            }
            else
            {
                // Message Sent Failed, You may want to retry
            }
        }
    }
}